/**
 * @author 黄波
 * 创建日期：2011Sep 28, 2011
 * TODO// N/A
 */
package com.platform.common.action;

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;

import com.platform.common.bo.CommonBo;
import com.platform.pojo.SchoolProperty;

/**
 * 获得所有班级信息
 */
public class GetClassesAction extends CommonSupport {


	private String isClass;
	private List<SchoolProperty> sps;
	private String msg;
	private boolean success;
	public String getIsClass() {
		return isClass;
	}
	public void setIsClass(String isClass) {
		this.isClass = isClass;
	}
	public List<SchoolProperty> getSps() {
		return sps;
	}
	public void setSps(List<SchoolProperty> sps) {
		this.sps = sps;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public boolean isSuccess() {
		return success;
	}
	public void setSuccess(boolean success) {
		this.success = success;
	}
	

	@Override
	public String execute() throws Exception {
		if(isClass == null) {
			isClass = "1";
		}

		CommonBo bo = CommonBo.getInstance();
		sps = bo.getclasses(isClass);

		success = true;
		HashMap map = new HashMap();
		map.put("sps", sps);
		map.put("msg", msg);
		map.put("success", success);
		JSONObject json = JSONObject.fromObject(map);
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		out.println(json);
		out.flush();
		out.close();
		return null;
	}
}
